-
Notifications
You must be signed in to change notification settings - Fork 273
CMake build system: support system-provided MiniSat #7644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake build system: support system-provided MiniSat #7644
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #7644 +/- ##
===========================================
- Coverage 78.55% 78.21% -0.35%
===========================================
Files 1691 1691
Lines 193125 193125
===========================================
- Hits 151712 151051 -661
- Misses 41413 42074 +661 ☔ View full report in Codecov by Sentry. |
src/solvers/CMakeLists.txt
Outdated
@@ -87,6 +87,15 @@ foreach(SOLVER ${sat_impl}) | |||
target_sources(solvers PRIVATE ${minisat2_source}) | |||
|
|||
target_link_libraries(solvers minisat2-condensed) | |||
elseif("${SOLVER}" STREQUAL "system-minisat2") | |||
include(CheckIncludeFileCXX) | |||
CHECK_INCLUDE_FILE_CXX("minisat/simp/SimpSolver.h" minisat_header_found) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 From CMake 3.12 CHECK_INCLUDE_FILE_CXX
can also check the existence of a counterpart library component by using CMAKE_REQUIRED_LIBRARIES
.
It may be worth increasing the minimum cmake required version and check for the library as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving beyond 3.10 would mean CBMC no longer builds (with CMake) on Ubuntu 18.04. Perhaps not a very strong argument as that is long deprecated, but still. So for now I've just added a comment reflecting what you educated me about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving beyond 3.10 would mean CBMC no longer builds (with CMake) on Ubuntu 18.04. Perhaps not a very strong argument as that is long deprecated, but still. So for now I've just added a comment reflecting what you educated me about.
I'd like to keep build on Ubuntu 18.04 alive for a little bit longer -- this is/was an incredibly popular choice, not least for university academics, but well beyond that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth noting that the Ubuntu 18.04 CI jobs were removed in this PR - #7657
The runners for github actions no longer support Ubuntu 18.04. So we had no straight forward way to keep the checks operational. It could potentially be done, but would require porting them over to docker. As such it is currently only a matter of time before issues are introduced which accidentally break the Ubuntu 18.04 build.
The changes looks good to me. @NlightNFotis We can specifically mark that using |
93be70a
to
5ce5e2e
Compare
Hello, I have tried to build this branch locally and I have not been able to do so. I have installed
The error message comes from an addition of an if(${minisat_header_found})
message(STATUS "Building solvers with minisat2 (pre-built)")
target_compile_definitions(solvers PUBLIC SATCHECK_MINISAT2 HAVE_MINISAT2)
target_sources(solvers PRIVATE ${minisat2_source})
target_link_libraries(solvers minisat)
else()
message(FATAL_ERROR "Unable to find header file for preinstalled Minisat2")
endif() The confusing thing is that I do have it installed, and I can find the header file: cbmc git:(5ce5e2e9b1) ✗ find `brew --prefix` | grep minisat/simp/SimpSolver.h
/opt/homebrew/Cellar/minisat/2.2.1/include/minisat/simp/SimpSolver.h I have tried to get the directory in the list of included directories of CMake after some googling/stack-overflowing, but my CMake-fu is failing me. This is what I ended up with but it doesn't seem to be working: elseif("${SOLVER}" STREQUAL "system-minisat2")
list(APPEND CMAKE_INCLUDE_PATH "/opt/homebrew/Cellar/minisat/2.2.1/include/")
include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
# if/when we move to CMake 3.12 (or later) we could also check for the
# library via CMAKE_REQUIRED_LIBRARIES
CHECK_INCLUDE_FILE_CXX("minisat/simp/SimpSolver.h" minisat_header_found)
if(${minisat_header_found})
message(STATUS "Building solvers with minisat2 (pre-built)")
target_compile_definitions(solvers PUBLIC SATCHECK_MINISAT2 HAVE_MINISAT2)
target_sources(solvers PRIVATE ${minisat2_source})
target_link_libraries(solvers minisat)
else()
message(FATAL_ERROR "Unable to find header file for preinstalled Minisat2")
endif()
elseif("${SOLVER}" STREQUAL "glucose") I was (crudely) trying to get the include path fixed, to get past compilation, but it didn't seem to be that responsive to my probes. Any insight on how to get past this? @tautschnig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing this with @NlightNFotis showed that when installing minisat
with homebrew
, CHECK_INCLUDE_FILE_CXX
cannot find the header file.
It is also hard (I didn't find a way) to instruct CHECK_INCLUDE_FILE_CXX
to look into a specific folder.
I would suggest to use a more robust mechanism to find an external dependency such as find_package
. This will enable the user to specify additional folders to look into (as well as it will allow to check for the minisat
library component as well as the header).
The update version of this PR now includes a fix that will make sure also the minisat object files get included. |
5ce5e2e
to
e9d3f9b
Compare
Package mirrors seem to be having a problem at this time: actions/runner-images#7596 |
I am now using |
Some operating systems provide packaged versions of MiniSat. When building distribution packages it may then be preferable to use the pre-installed library instead of building the solver object from scratch. With this patch it is now possible to select "system-minisat2" as a solver, alongside any other solvers that may be built from scratch. The required support for external libraries also addresses diffblue#7641. Fixes: diffblue#7641
e9d3f9b
to
3246c2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a non-crucial comment, but as it is a solid improvement wrt the state of the art I will approve.
@tautschnig Regarding the failure on In the future it will be interesting to fix the problem as |
The fix here would be to either submit patches to homebrew or work around the problem by silencing some warnings via cmake command line compiler flags. The former is out of scope, the latter people interested in this can do locally? |
Co-authored-by: Enrico Steffinlongo <[email protected]>
Some operating systems provide packaged versions of MiniSat. When building distribution packages it may then be preferable to use the pre-installed library instead of building the solver object from scratch. With this patch it is now possible to select "system-minisat2" as a solver, alongside any other solvers that may be built from scratch.